package com.mybatis.flex.global;


import com.mybatis.flex.entity.Account;
import com.mybatis.flex.listener.FlexInsertListener;
import com.mybatis.flex.listener.FlexUpdateListener;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisFlexConfiguration implements MyBatisFlexCustomizer {
    @Override
    public void customize(FlexGlobalConfig flexGlobalConfig) {
        FlexInsertListener insertListener = new FlexInsertListener();
        FlexUpdateListener updateListener = new FlexUpdateListener();
       // MySetListener setListener = new MySetListener();

        FlexGlobalConfig config = FlexGlobalConfig.getDefaultConfig();

        config.registerInsertListener(insertListener, Account.class);
        config.registerUpdateListener(updateListener, Account.class);
        //config.registerSetListener(setListener, Entity1.class, Entity2.class);
        //开启审计功能
        AuditManager.setAuditEnable(true);
    }
}
